package com.hwadee.teachingprocessmanagementsystem.service.base.impl;

import com.hwadee.teachingprocessmanagementsystem.entity.Classroom;
import com.hwadee.teachingprocessmanagementsystem.dao.ClassroomDao;
import com.hwadee.teachingprocessmanagementsystem.service.base.ClassroomService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import jakarta.annotation.Resource;

import java.util.List;

/**
 * 教室表(Classroom)表服务实现类
 *
 * @author makejava
 * @since 2024-07-11 14:20:02
 */
@Service("classroomService")
public class ClassroomServiceImpl implements ClassroomService {
    @Resource
    private ClassroomDao classroomDao;

    /**
     * 通过ID查询单条数据
     *
     * @param classroomId 主键
     * @return 实例对象
     */
    @Override
    public Classroom queryById(Integer classroomId) {
        return this.classroomDao.queryById(classroomId);
    }


    /**
     * 新增数据
     *
     * @param classroom 实例对象
     * @return 实例对象
     */
    @Override
    public Classroom insert(Classroom classroom) {
        this.classroomDao.insert(classroom);
        return classroom;
    }

    /**
     * 修改数据
     *
     * @param classroom 实例对象
     * @return 实例对象
     */
    @Override
    public Classroom update(Classroom classroom) {
        this.classroomDao.update(classroom);
        return this.queryById(classroom.getClassroomId());
    }

    /**
     * 通过主键删除数据
     *
     * @param classroomId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer classroomId) {
        return this.classroomDao.deleteById(classroomId) > 0;
    }

    @Override
    public List<Classroom> queryAllByLimit(Classroom classroom) {
        return this.classroomDao.queryAllByLimit(classroom);
    }
}
